package com.hqd.ch03.v40.web.servlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 视图接口
 */
public interface View {
    String RESPONSE_STATUS_ATTRIBUTE = View.class.getName() + ".responseStatus";

    /**
     * 例：/users/{userId}/posts/{postId}
     * 变量路径，这里没有支持
     */
    String PATH_VARIABLES = View.class.getName() + ".pathVariables";

    /**
     * 确定返回类型
     */
    String SELECTED_CONTENT_TYPE = View.class.getName() + ".selectedContentType";

    default String getContentType() {
        return null;
    }

    void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response)
            throws Exception;
}
